<?php

/**
 * Usuario form base class.
 *
 * @method Usuario getObject() Returns the current form's model object
 *
 * @package    ecampus
 * @subpackage form
 * @author     Grupo 608
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseUsuarioForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_usuario'                => new sfWidgetFormInputHidden(),
      'nombre_usuario'            => new sfWidgetFormInputText(),
      'password'                  => new sfWidgetFormInputText(),
      'fecha_ultima_modificacion' => new sfWidgetFormDateTime(),
      'tipo_usuario'              => new sfWidgetFormInputText(),
      'nombre'                    => new sfWidgetFormInputText(),
      'apellido'                  => new sfWidgetFormInputText(),
      'email'                     => new sfWidgetFormInputText(),
      'imagen'                    => new sfWidgetFormTextarea(),
      'activo'                    => new sfWidgetFormInputText(),
      'administrador'             => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id_usuario'                => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id_usuario')), 'empty_value' => $this->getObject()->get('id_usuario'), 'required' => false)),
      'nombre_usuario'            => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'password'                  => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'fecha_ultima_modificacion' => new sfValidatorDateTime(array('required' => false)),
      'tipo_usuario'              => new sfValidatorString(array('max_length' => 1, 'required' => false)),
      'nombre'                    => new sfValidatorString(array('max_length' => 25, 'required' => false)),
      'apellido'                  => new sfValidatorString(array('max_length' => 25, 'required' => false)),
      'email'                     => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'imagen'                    => new sfValidatorString(array('required' => false)),
      'activo'                    => new sfValidatorInteger(array('required' => false)),
      'administrador'             => new sfValidatorInteger(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'Usuario', 'column' => array('nombre_usuario'))),
        new sfValidatorDoctrineUnique(array('model' => 'Usuario', 'column' => array('email'))),
      ))
    );

    $this->widgetSchema->setNameFormat('usuario[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Usuario';
  }

}
